

use "$path\Intermediary Data\base_CIR", clear
merge 1:1 id using "$path\Intermediary Data\moments_alt.dta"
sum kurtosis , d
local min=2.5
local max=97.5
winsor2 kurtosis , replace  cuts(`min' `max') trim
replace kurto=. if kurto>9
sum kurtosis , d
keep if _m==3
drop _m
merge 1:1 id using "$path\Intermediary Data\moments_EG"
sum freq , d
local min=2.5
local max=97.5
winsor2 freq , replace  cuts(`min' `max') trim
sum freq , d
egen tot=sum(nobs)
keep if _m==3
drop _m
merge 1:1 id using "$path\Intermediary Data\kurto_hetero"
sum k_10 , d
local min=2.5
local max=97.5
winsor2 k_10 , replace  cuts(`min' `max') trim
sum k_10 , d
winsor2 k_5 , replace  cuts(`min' `max') trim
sum k_5, d
winsor2 k_15 , replace  cuts(`min' `max') trim
sum k_15, d
winsor2 k_20 , replace  cuts(`min' `max') trim
sum k_20, d
winsor2 k_25 , replace  cuts(`min' `max') trim
sum k_25, d
keep if _m==3
drop _m

sum CIR_2 , d
local min=1
local max=99
winsor2 CIR_2 , replace  cuts(`min' `max') trim
winsor2 CIR_2_MA , replace  cuts(`min' `max') trim
winsor2 CIR_2_24 , replace  cuts(`min' `max') trim
winsor2 CIR_2_18 , replace  cuts(`min' `max') trim
winsor2 CIR_2_36 , replace  cuts(`min' `max') trim


winsor2 CIR_2_30_brentonly , replace  cuts(`min' `max') trim
winsor2 CIR_2_24_brentonly , replace  cuts(`min' `max') trim



sum nobs, d
sum sc10, d


sum CIR_2,d

gen ratio=kurtosis/freq
sum ratio, d
local min=1
local max=99
winsor2 ratio , replace  cuts(`min' `max') trim
replace freq=. if ratio==.
replace kurt=. if ratio==.

replace ratio=kurtosis/freq

gen ratio_10=k_10/freq
gen ratio_5=k_5/freq
gen ratio_15=k_15/freq
gen ratio_20=k_20/freq
gen ratio_25=k_25/freq

drop if ratio==.
drop if CIR_2==.


sort nobs
gen sum_obs=sum(nobs)

gen year=(nobs/261)
gen share_obs=1-sum_obs/13712161
egen sum1=sum(nobs) if year>=1
egen sum2=sum(nobs) if year>=2

egen sum3=sum(nobs) if year>=3
egen sum4=sum(nobs) if year>=4
egen sum5=sum(nobs) if year>=5
egen sum6=sum(nobs) if year>=6
egen sum7=sum(nobs) if year>=7
egen sum8=sum(nobs) if year>=8
egen sum9=sum(nobs) if year>=9
egen sum10=sum(nobs) if year>=10

sum sum* tot

sum k*, d



preserve
keep if year>=6

save "$path\Intermediary Data\base_suff_stat_6Y", replace

keep id
duplicates drop id, force
save "$path\Intermediary Data\base_id_suff_stat_6Y", replace
restore

preserve
keep if year>=4

save "$path\Intermediary Data\base_suff_stat_4Y", replace

keep id
duplicates drop id, force
save "$path\Intermediary Data\base_id_suff_stat_4Y", replace
restore


preserve
keep if year>=2

save "$path\Intermediary Data\base_suff_stat_2Y", replace

keep id
duplicates drop id, force
save "$path\Intermediary Data\base_id_suff_stat_2Y", replace
restore

preserve
keep if year>=8

save "$path\Intermediary Data\base_suff_stat_8Y", replace

keep id
duplicates drop id, force
save "$path\Intermediary Data\base_id_suff_stat_8Y", replace
restore

*** Create light data for merge later - 6Y
clear
use "$path\Intermediary Data\base_suff_stat_6Y"
keep id lt_effect* kurtosis freq ratio mean skewness sd k_20 k_10 k_15 k_25
save "$path\Intermediary Data\base_base_suff_stat_6Y_forinteractkurtfreq", replace


*** Create light data for merge later - 2Y
clear
use "$path\Intermediary Data\base_suff_stat_2Y"
keep id lt_effect* kurtosis freq ratio mean skewness sd k_20 k_10 k_15 k_25
save "$path\Intermediary Data\base_base_suff_stat_2Y_forinteractkurtfreq", replace

*** Create light data for merge later - 4Y
clear
use "$path\Intermediary Data\base_suff_stat_4Y"
keep id lt_effect* kurtosis freq ratio mean skewness sd k_20 k_10 k_15 k_25
save "$path\Intermediary Data\base_base_suff_stat_4Y_forinteractkurtfreq", replace

*** Create light data for merge later - 8Y
clear
use "$path\Intermediary Data\base_suff_stat_8Y"
keep id lt_effect kurtosis freq ratio mean skewness sd k_20 k_10 k_15 k_25
save "$path\Intermediary Data\base_base_suff_stat_8Y_forinteractkurtfreq", replace
